{	Problem: http://codeforces.ru/problemset/problem/34/B
	Verdict: Accepted

}
var a:array[1..101] of longint; i,n,m,sum:longint;
procedure qsort(l,r:integer);
var i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
  while a[i]<x do inc(i);
  while a[j]>x do dec(j);
  if i<=j then begin
    y:=a[i];
    a[i]:=a[j];
    a[j]:=y;
    inc(i);
    dec(j);
  end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(n,m);
for i:=1 to n do read(a[i]);
qsort(1,n);
sum:=0;
for i:=1 to m do if a[i]<0 then inc(sum,a[i]);
writeln(abs(sum));
end.
